home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / pstools / psscale.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.9 KB  |  131 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    pspatch    -
  19.  *        Make calibration patches.
  20.  *
  21.  *                    Paul Haeberli - 1990
  22.  */
  23. #include "stdio.h"
  24.  
  25. main(argc,argv)
  26. int argc;
  27. char **argv;
  28. {
  29.     if (argc<2) 
  30.     bwscale();
  31.     else
  32.     cmykscale();
  33. }
  34.  
  35. cmykscale()
  36. {
  37.     int i, j, g;
  38.     float fg;
  39.  
  40.     beginps(stdout,8.5/11.0,0.0,72*8.5,0.0,72*11.0);
  41.     pssetfont("Times-Roman",10.0);
  42.     pstranslate(36.0,36.0);
  43.     pslinewidth(0.5);
  44.     printf("/oneblock {\n");
  45.     psgsave();
  46.     printf("translate ");
  47.     psrectf(0.0,0.0,24.0,24.0);
  48.     psgrey(0.0);
  49.     psrect(0.0,0.0,24.0,24.0);
  50.     psmoveto(-1.0,-10.0);
  51.     printf("show\n");
  52.     psgrestore();
  53.     printf("} bind def\n\n");
  54.  
  55.     psgsave();
  56.     pstranslate(36.0,40.0);
  57.     for(j=0; j<5; j++) {
  58.     for(i=0; i<=32; i++) {
  59.         g = i*8;
  60.         if(g>255)
  61.         g = 255;
  62.         fg = g/255.0;
  63.         switch(j) {
  64.         case 0:
  65.             printf("(cyn %d) ",g);
  66.             pscmyk(fg,0.0,0.0,0.0);
  67.             break;
  68.         case 1:
  69.             printf("(mag %d) ",g);
  70.             pscmyk(0.0,fg,0.0,0.0);
  71.             break;
  72.         case 2:
  73.             printf("(yel %d) ",g);
  74.             pscmyk(0.0,0.0,fg,0.0);
  75.             break;
  76.         case 3:
  77.             printf("(blk %d) ",g);
  78.             pscmyk(0.0,0.0,0.0,fg);
  79.             break;
  80.         case 4:
  81.             printf("(rgbg %d) ",g);
  82.             psrgb(fg,fg,fg);
  83.             break;
  84.         }
  85.         if(i>=16)
  86.         printf("%f %f\n",2*40.0*j+40.0,40.0*(i-16));
  87.         else
  88.         printf("%f %f\n",2*40.0*j,40.0*i);
  89.         printf("oneblock\n");
  90.     }
  91.     }
  92.     pscmyk(1.0,1.0,1.0,1.0);
  93.     pstranslate(2*40.0*5,40.0*8);
  94.     psrectf(0.0,0.0,24.0,24.0);
  95.     psgrey(0.0);
  96.     psrect(0.0,0.0,24.0,24.0);
  97.     psmoveto(0.0,-8.0);
  98.     psgrestore();
  99.     endps();
  100. }
  101.  
  102. bwscale()
  103. {
  104.     int i, x, y;
  105.  
  106.     beginps(stdout,8.5/11.0,0.0,72*8.5,0.0,72*11.0);
  107.     pssetfont("Times-Roman",10.0);
  108.     pstranslate(36.0,36.0);
  109.     pslinewidth(0.5);
  110.     printf("/bwblock {\n");
  111.     psgsave();
  112.     printf("translate\n");
  113.     printf("setgray\n");
  114.     psrectf(0.0,0.0,24.0,24.0);
  115.     printf("0.0 setgray\n");
  116.     psrect(0.0,0.0,24.0,24.0);
  117.     psmoveto(0.0,-8.0);
  118.     printf("show\n",i);
  119.     psgrestore();
  120.     printf("} bind def\n");
  121.     for(i=0; i<256; i++) {
  122.     x = i%16;
  123.     y = i/16;
  124.     printf("(%d) ",i);
  125.     printf("%f ",1.00*i/255.0);
  126.     printf("%f %f ",24.0*x,40.0*y);
  127.     printf("bwblock\n");
  128.     }
  129.     endps();
  130. }
  131.